package io.renren.modules.matlist.service.impl;

import io.renren.modules.matlist.service.PalletService;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

@Service
public class PalletServiceImpl implements PalletService {

    @Override
//    public String getPalletInfo(String palletCode) {
    public String getPalletInfo(String container) {
        RestTemplate restTemplate = new RestTemplate();

        Map<String, Object> requestBody = new HashMap<>();
        Map<String, String> inputs = new HashMap<>();
//        inputs.put("PalletCode", palletCode);
        inputs.put("Container", container);
        requestBody.put("Inputs", inputs);

        HttpEntity<Map<String, Object>> entity = new HttpEntity<>(requestBody);

        ResponseEntity<String> response = restTemplate.exchange(
                "https://10.143.7.35/Apriso/httpServices/operations/IF_MES_UWB_GetContainerInfo",
                HttpMethod.POST,
                entity,
                String.class
        );
        System.out.println("======这是托盘内数据========");
        System.out.println(response.getBody());
        System.out.println("======这是托盘内数据========");
        return response.getBody();
    }
}

